package acm.pta10;

import java.util.*;

public class 二叉搜索树节点个数 {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n = sc.nextInt();
        root=null;
        maxLevel=0;
        sc.nextLine();
        for (int i = 0; i < n; i++) {
            add(sc.nextInt());
        }
        System.out.println(fun(root));
    }
    static Tree root;
    static int maxLevel;
    public static void add(int val){
        if (root==null){
            root=new Tree(1,val);
            maxLevel=1;
            return;
        }
        Tree curr=root;
        Tree parent=curr;
        while (curr!=null){
            parent=curr;
            if (val>curr.val){
                curr=curr.right;
            }else {
                curr=curr.left;
            }
        }
        Tree node = new Tree(parent.level + 1, val);
        if (parent.val>=val) {
            parent.left=node;
        }else {
            parent.right =node;
        }
        maxLevel=Math.max(maxLevel,node.level);
    }

    public static int fun(Tree tree){
        if (tree==null) return 0;
        int res=0;
        if (maxLevel-1<=tree.level){
            res=1;
        }
        int left = fun(tree.left);
        int right = fun(tree.right);
        return res+left+right;
    }

    public static long byLevel(Tree tree){
        if (tree==null) return 0;
        Queue<Tree> queue = new LinkedList<>();
        long[] levels=new long[maxLevel+1];
        queue.add(tree);
        while (!queue.isEmpty()) {
            Tree poll = queue.poll();
            levels[poll.level]++;
            if (poll.left!=null)queue.add(poll.left);
            if (poll.right!=null)queue.add(poll.right);
        }
        return levels[maxLevel-1]+levels[maxLevel];
    }

    static class Tree{
        int level;
        int val;
        Tree left;
        Tree right;

        public Tree(int level, int val) {
            this.level = level;
            this.val = val;
        }
    }
}
